Exemplo n.º 1
0
xme_status_t
detector_adv_logger_loggerComponentWrapper_readPortInfo
(
    const detector_topic_device_info_t* data
)
{
    uint8_t inputPortIndex;
    unsigned int bytesRead;
    xme_status_t status;
#ifdef XME_MULTITHREAD
    char* accessed;
#endif // #ifdef XME_MULTITHREAD

    XME_CHECK(NULL != data, XME_STATUS_INVALID_PARAMETER);

    inputPortIndex = (uint8_t)DETECTOR_ADV_LOGGER_LOGGERCOMPONENTWRAPPER_PORT_INFO;

#ifdef XME_MULTITHREAD
    XME_ASSERT(inputPortAccessed != XME_HAL_TLS_INVALID_TLS_HANDLE);
    accessed = (char*) xme_hal_tls_get(inputPortAccessed);
    XME_ASSERT(NULL != accessed);

    if (!(accessed[inputPortIndex / 8U] & (1 << (inputPortIndex % 8U))))
#else // #ifdef XME_MULTITHREAD
    if (!inputPorts[inputPortIndex].state.locked)
#endif // #ifdef XME_MULTITHREAD
    {
        status = xme_core_dataHandler_startReadOperation(inputPorts[inputPortIndex].dataPacketId);
        XME_CHECK(XME_STATUS_SUCCESS == status, XME_STATUS_INTERNAL_ERROR);
#ifdef XME_MULTITHREAD
        accessed[inputPortIndex / 8U] |= (1 << (inputPortIndex % 8U));
#endif // #ifdef XME_MULTITHREAD
        inputPorts[inputPortIndex].state.locked = 1;
    }

    status = xme_core_dataHandler_readData
    (
        inputPorts[inputPortIndex].dataPacketId,
        (void*)data,
        (uint32_t)sizeof(detector_topic_device_info_t),
        &bytesRead
    );

    if (XME_STATUS_SUCCESS == status)
    {
        inputPorts[inputPortIndex].state.dataValid = 1;
    }
    else
    {
        inputPorts[inputPortIndex].state.error = 1;
    }

    return status;
}
Exemplo n.º 2
0
xme_status_t
sensorMonitor_adv_monitorB_monitorBComponentWrapper_readInputPortAttribute
(
    sensorMonitor_adv_monitorB_monitorBComponentWrapper_internalPortId_t portId,
    xme_core_attribute_key_t attributeKey,
    void* const buffer,
    uint32_t bufferSize
)
{
    xme_status_t status;
    uint8_t inputPortIndex;
    uint32_t bytesRead = 0U;
#ifdef XME_MULTITHREAD
    char* accessed;
#endif // #ifdef XME_MULTITHREAD

    inputPortIndex = (uint8_t)portId;

#ifdef XME_MULTITHREAD
    XME_ASSERT(inputPortAccessed != XME_HAL_TLS_INVALID_TLS_HANDLE);
    accessed = (char*) xme_hal_tls_get(inputPortAccessed);
    XME_ASSERT(NULL != accessed);

    if (!(accessed[inputPortIndex / 8U] & (1 << (inputPortIndex % 8U))))
#else // #ifdef XME_MULTITHREAD
    if (!inputPorts[inputPortIndex].state.locked)
#endif // #ifdef XME_MULTITHREAD
    {
        status = xme_core_dataHandler_startReadOperation(inputPorts[inputPortIndex].dataPacketId);
        XME_CHECK(XME_STATUS_SUCCESS == status, XME_STATUS_INTERNAL_ERROR);
#ifdef XME_MULTITHREAD
        accessed[inputPortIndex / 8U] |= (1 << (inputPortIndex % 8U));
#endif // #ifdef XME_MULTITHREAD
        inputPorts[inputPortIndex].state.locked = 1;
    }

    status = xme_core_dataHandler_readAttribute
    (
        inputPorts[inputPortIndex].dataPacketId,
        attributeKey,
        buffer,
        bufferSize,
        &bytesRead
    );

    if (XME_STATUS_SUCCESS == status)
    {
        inputPorts[inputPortIndex].state.attributesValid = 1;
    }

    // FIXME: Check bytesRead

    return status;
}
Exemplo n.º 3
0
xme_status_t
sensorMonitor_adv_monitorB_monitorBComponentWrapper_readPortSensorValueIn
(
    const sensorMonitor_topic_sensorData_t* data
)
{
    uint8_t inputPortIndex;
    unsigned int bytesRead;
    xme_status_t status;
#ifdef XME_MULTITHREAD
    char* accessed;
#endif // #ifdef XME_MULTITHREAD

    XME_CHECK(NULL != data, XME_STATUS_INVALID_PARAMETER);

    inputPortIndex = (uint8_t)SENSORMONITOR_ADV_MONITORB_MONITORBCOMPONENTWRAPPER_PORT_SENSORVALUEIN;

#ifdef XME_MULTITHREAD
    XME_ASSERT(inputPortAccessed != XME_HAL_TLS_INVALID_TLS_HANDLE);
    accessed = (char*) xme_hal_tls_get(inputPortAccessed);
    XME_ASSERT(NULL != accessed);

    if (!(accessed[inputPortIndex / 8U] & (1 << (inputPortIndex % 8U))))
#else // #ifdef XME_MULTITHREAD
    if (!inputPorts[inputPortIndex].state.locked)
#endif // #ifdef XME_MULTITHREAD
    {
        status = xme_core_dataHandler_startReadOperation(inputPorts[inputPortIndex].dataPacketId);
        XME_CHECK(XME_STATUS_SUCCESS == status, XME_STATUS_INTERNAL_ERROR);
#ifdef XME_MULTITHREAD
        accessed[inputPortIndex / 8U] |= (1 << (inputPortIndex % 8U));
#endif // #ifdef XME_MULTITHREAD
        inputPorts[inputPortIndex].state.locked = 1;
    }

    status = xme_core_dataHandler_readData
    (
        inputPorts[inputPortIndex].dataPacketId,
        (void*)data,
        (uint32_t)sizeof(sensorMonitor_topic_sensorData_t),
        &bytesRead
    );

    if (XME_STATUS_SUCCESS == status)
    {
        inputPorts[inputPortIndex].state.dataValid = 1;
    }
    else
    {
        inputPorts[inputPortIndex].state.error = 1;
    }

    return status;
}
Exemplo n.º 4
0
xme_status_t
xme_core_directory_nodeRegistryController_addInterface
(
    xme_core_node_nodeId_t nodeId,
    xme_com_interface_address_t interfaceAddress
)
{
    xme_hal_table_rowHandle_t handle;
    xme_core_node_nodeData_t* nodeItem;
    xme_com_interface_address_t* newInterfaceAddress;

    XME_CHECK(XME_CORE_NODE_INVALID_NODE_ID != nodeId, XME_STATUS_INVALID_PARAMETER);

    // Search for an existing item for this node
    handle = XME_HAL_TABLE_INVALID_ROW_HANDLE;
    nodeItem = NULL;
    XME_HAL_TABLE_GET_NEXT(xme_core_directory_nodeRegistryController_nodeTable, xme_hal_table_rowHandle_t, handle, xme_core_node_nodeData_t, nodeItem, nodeItem->nodeId == nodeId);

    // The node should already be registered
    XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_NOT_FOUND);
    
    if (nodeItem != NULL)
    {
        if (0 != XME_HAL_TABLE_ITEM_COUNT(nodeItem->interfaces))
        {
            xme_hal_table_rowHandle_t rh = XME_HAL_TABLE_INVALID_ROW_HANDLE;
            xme_com_interface_address_t *interfaceItem = NULL;
            XME_HAL_TABLE_GET_NEXT
            (
                nodeItem->interfaces, 
                xme_hal_table_rowHandle_t, rh, 
                xme_com_interface_address_t, interfaceItem, 
                interfaceItem->addressType == interfaceAddress.addressType
            );
            while (NULL != interfaceItem)
            {
                if (0 == xme_hal_mem_compare(interfaceItem, &interfaceAddress, sizeof(xme_com_interface_address_t))) 
                {
                    return XME_STATUS_ALREADY_EXIST;
                }
                interfaceItem = NULL;
                XME_HAL_TABLE_GET_NEXT
                (
                    nodeItem->interfaces, 
                    xme_hal_table_rowHandle_t, rh, 
                    xme_com_interface_address_t, interfaceItem, 
                    interfaceItem->addressType == interfaceAddress.addressType
                );
            }
        }
        handle = XME_HAL_TABLE_ADD_ITEM(nodeItem->interfaces);
        XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_OUT_OF_RESOURCES);
        newInterfaceAddress = (xme_com_interface_address_t*) XME_HAL_TABLE_ITEM_FROM_HANDLE(nodeItem->interfaces, handle);
        XME_ASSERT(NULL != newInterfaceAddress);

        (void) xme_hal_mem_copy(newInterfaceAddress, &interfaceAddress, sizeof(xme_com_interface_address_t));
    }

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 5
0
xme_status_t
xme_core_directory_nodeRegistryController_deregisterNode
(
    xme_core_node_nodeId_t nodeID
)
{
    xme_hal_table_rowHandle_t handle;
    xme_core_node_nodeData_t* nodeItem;
    xme_status_t status;

    XME_CHECK(XME_CORE_NODE_INVALID_NODE_ID != nodeID, XME_STATUS_INVALID_PARAMETER);

    // Search for an existing item for this node
    handle = XME_HAL_TABLE_INVALID_ROW_HANDLE;
    nodeItem = NULL;
    XME_HAL_TABLE_GET_NEXT
    (
        xme_core_directory_nodeRegistryController_nodeTable, 
        xme_hal_table_rowHandle_t, 
        handle, 
        xme_core_node_nodeData_t, 
        nodeItem, 
        nodeItem->nodeId == nodeID
    );

    // The node id is not registered
    XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_NOT_FOUND);

    status = XME_HAL_TABLE_REMOVE_ITEM(xme_core_directory_nodeRegistryController_nodeTable, handle);
    XME_ASSERT(XME_STATUS_SUCCESS == status);

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 6
0
xme_status_t
reapplyManipulations
(
    xme_core_dataManager_dataStoreID_t dataStoreID
)
{
    xme_core_dataHandler_database_manipulationItem_t* manipulationItem = NULL;
    xme_hal_table_rowHandle_t internalHandle = XME_HAL_TABLE_INVALID_ROW_HANDLE;

    do
    {
        void* returnAddress;

        // Obtain the next element. 
        XME_HAL_TABLE_GET_NEXT
        (
            manipulationsTable,
            xme_hal_table_rowHandle_t, internalHandle, 
            xme_core_dataHandler_database_manipulationItem_t, manipulationItem, 
            (manipulationItem->dataStoreID == dataStoreID)
        );

        if (XME_HAL_TABLE_INVALID_ROW_HANDLE == internalHandle) continue;

        XME_ASSERT(NULL != manipulationItem);

        returnAddress = xme_hal_mem_copy((void*) manipulationItem->address, &(manipulationItem->value), sizeof(manipulationItem->value));
        XME_CHECK(returnAddress == (void*) manipulationItem->address, XME_STATUS_INTERNAL_ERROR);
    } 
    while(XME_HAL_TABLE_INVALID_ROW_HANDLE != internalHandle);

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 7
0
xme_status_t
sensorMonitor_adv_monitorB_monitorBComponentWrapper_readNextPacket
(
    sensorMonitor_adv_monitorB_monitorBComponentWrapper_internalPortId_t portId
)
{
    xme_status_t status = XME_STATUS_SUCCESS;
#ifdef XME_MULTITHREAD
    char* accessed;
#endif // #ifdef XME_MULTITHREAD

    XME_ASSERT(portId < inputPortCount);

#ifdef XME_MULTITHREAD
    XME_ASSERT(inputPortAccessed != XME_HAL_TLS_INVALID_TLS_HANDLE);
    accessed = (char*) xme_hal_tls_get(inputPortAccessed);
    XME_ASSERT(NULL != accessed);

    // We need to complete the read operation if the port has been accessed
    if (accessed[portId / 8U] & (1 << (portId % 8U)))
#else // #ifdef XME_MULTITHREAD
    if (inputPorts[portId].state.locked)
#endif // #ifdef XME_MULTITHREAD
    {
        status = xme_core_dataHandler_completeReadOperation(inputPorts[portId].dataPacketId);
        XME_CHECK_MSG
        (
            XME_STATUS_SUCCESS == status,
            XME_STATUS_INTERNAL_ERROR,
            XME_LOG_ERROR,
            "[monitorBComponentWrapper] CompleteReadOperation for port (interalPortId: %d, dataPacketId: %d) returned error code %d.\n",
            portId, inputPorts[portId].dataPacketId, status
        );

#ifdef XME_MULTITHREAD
        accessed[portId / 8U] &= ~(1 << (portId % 8U));
#endif // #ifdef XME_MULTITHREAD
        inputPorts[portId].state.dataValid = 0;
        inputPorts[portId].state.attributesValid = 0;
        inputPorts[portId].state.locked = 0;
        inputPorts[portId].state.error = 0;
    }

    return status;
}
Exemplo n.º 8
0
xme_status_t
xme_wp_marshal_marshaler_getConfig
(
    xme_wp_waypoint_instanceId_t* instanceId,
    xme_core_topic_t* topic,
    xme_core_dataManager_dataPacketId_t* inputPort,
    xme_core_dataManager_dataPacketId_t* outputPort
)
{
    xme_hal_table_rowHandle_t rowHandle = XME_HAL_TABLE_INVALID_ROW_HANDLE;
    configurationItem_t* configItem = NULL;
    
    // Check parameters in debug build only
    XME_ASSERT(NULL != instanceId);
    XME_ASSERT(NULL != topic);
    XME_ASSERT(NULL != inputPort);
    XME_ASSERT(NULL != outputPort);
    
    XME_HAL_TABLE_GET_NEXT
    (
        configurationTable,
        xme_hal_table_rowHandle_t,
        rowHandle,
        configurationItem_t,
        configItem,
        (
            (XME_WP_WAYPOINT_INSTANCEID_INVALID == *instanceId  || rowHandle == (xme_hal_table_rowHandle_t)(*instanceId))
            && (XME_CORE_TOPIC_INVALID_TOPIC == *topic  || configItem->topic == *topic)
            && (XME_CORE_DATAMANAGER_DATAPACKETID_INVALID == *inputPort || configItem->inputPort == *inputPort)
            && (XME_CORE_DATAMANAGER_DATAPACKETID_INVALID == *outputPort || configItem->outputPort == *outputPort)
        )
    );
    
    if (XME_HAL_TABLE_INVALID_ROW_HANDLE != rowHandle)
    {
        *instanceId = (xme_wp_waypoint_instanceId_t)rowHandle;
        *topic = configItem->topic;
        *inputPort = configItem->inputPort;
        *outputPort = configItem->outputPort;
        
        return XME_STATUS_SUCCESS;
    }
    
    return XME_STATUS_NOT_FOUND;
}
Exemplo n.º 9
0
xme_status_t
xme_core_dataHandler_databaseTestProbe_endAttributeManipulation
(
    xme_core_dataManager_dataStoreID_t dataStoreID,
    uint32_t offset,
    uint32_t attributeKey
)
{
    xme_core_dataHandler_database_dataStore_t* dataStore;
    xme_core_dataHandler_database_attribute_t* attribute;
    void* databaseAddress;
    uintptr_t dataAddress;
    xme_status_t status;

    XME_ASSERT(NULL != xme_core_dataHandler_database);

    // Get the data packet information. 
    XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_NOT_FOUND);
    XME_CHECK(XME_STATUS_SUCCESS == getAttribute(dataStore, attributeKey, &attribute), XME_STATUS_INVALID_PARAMETER);

    if (offset > attribute->attributeValueSize)
    {
        return XME_STATUS_INVALID_CONFIGURATION;
    }

    databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW - 1U);
    XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND);
    dataAddress = (((uintptr_t) databaseAddress) + attribute->attributeOffset + offset);

    status = removeManipulation(dataStoreID, dataAddress);
    XME_CHECK(XME_STATUS_SUCCESS == status, status);

    if (0U == getNumberOfManipulationsForDataStore(dataStoreID))
    {
        dataStore->manipulated = false;

        // Activate master database.
        dataStore->activeDatabaseIndex = XME_CORE_DATAHANDLER_DATABASE_INDEX_MASTER;
    }
    else
    {
        status = copyBetweenMemoryRegionCopies
            (
                dataStoreID, 
                XME_CORE_DATAHANDLER_DATABASE_INDEX_MASTER, 
                XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW
            );
        XME_CHECK(XME_STATUS_SUCCESS == status, status);

        status = reapplyManipulations(dataStore->dataStoreID);
        XME_CHECK(XME_STATUS_SUCCESS == status, status);
    }

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 10
0
xme_status_t
xme_core_directory_nodeRegistryController_registerNode
(
    xme_core_node_nodeId_t nodeId,
    const char* nodeName,
    xme_core_node_guid_t guid
)
{
    xme_hal_table_rowHandle_t handle;
    xme_core_node_nodeData_t* nodeItem;

    XME_CHECK(XME_CORE_NODE_INVALID_NODE_ID != nodeId, XME_STATUS_INVALID_PARAMETER);
    XME_CHECK(NULL != nodeName, XME_STATUS_INVALID_PARAMETER);
    XME_CHECK(0 != guid, XME_STATUS_INVALID_PARAMETER);

    // Search for an existing item for this node
    handle = XME_HAL_TABLE_INVALID_ROW_HANDLE;
    nodeItem = NULL;
    XME_HAL_TABLE_GET_NEXT
    (
        xme_core_directory_nodeRegistryController_nodeTable, 
        xme_hal_table_rowHandle_t, 
        handle, 
        xme_core_node_nodeData_t, 
        nodeItem, 
        nodeItem->nodeId == nodeId
    );
    {
        // The node should not yet be registered
        XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE == handle, XME_STATUS_ALREADY_EXIST);

        // Insert the node
        handle = XME_HAL_TABLE_ADD_ITEM(xme_core_directory_nodeRegistryController_nodeTable);
        XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_OUT_OF_RESOURCES);

        nodeItem = (xme_core_node_nodeData_t*) XME_HAL_TABLE_ITEM_FROM_HANDLE(xme_core_directory_nodeRegistryController_nodeTable, handle);
        XME_ASSERT(NULL != nodeItem);

        nodeItem->nodeId = nodeId;
        xme_hal_safeString_strncpy(nodeItem->nodeName, nodeName, sizeof(nodeItem->nodeName));
        nodeItem->guid = guid;
        XME_HAL_TABLE_INIT(nodeItem->interfaces);
    }

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 11
0
xme_status_t
sensorMonitor_adv_monitorB_monitorBComponentWrapper_init(void)
{
    if (0U == initializationCount)
    {
        #ifdef XME_MULTITHREAD
        if (XME_HAL_TLS_INVALID_TLS_HANDLE == inputPortAccessed)
        {
            inputPortAccessed = xme_hal_tls_alloc((inputPortCount + 7U) / 8U);
            XME_ASSERT(XME_HAL_TLS_INVALID_TLS_HANDLE != inputPortAccessed);
        }
        #endif // #ifdef XME_MULTITHREAD
    }

    initializationCount++;

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 12
0
xme_status_t
xme_core_directory_nodeRegistryController_initNodeInterfaceIterator
(
    xme_core_node_nodeId_t nodeId, 
    xme_com_interface_addressType_t addressType,
    xme_core_directory_nodeRegistryController_nodeInterfaceIterator_t **iterator
)
{
    xme_hal_table_rowHandle_t handle = XME_HAL_TABLE_INVALID_ROW_HANDLE;
    xme_core_node_nodeData_t* nodeItem = NULL;

    XME_CHECK(NULL != iterator, XME_STATUS_INVALID_PARAMETER);
    XME_CHECK(XME_CORE_NODE_INVALID_NODE_ID != nodeId, XME_STATUS_INVALID_PARAMETER);
    
    XME_HAL_TABLE_GET_NEXT
    (
        xme_core_directory_nodeRegistryController_nodeTable,
        xme_hal_table_rowHandle_t, handle,
        xme_core_node_nodeData_t, nodeItem,
        nodeItem->nodeId == nodeId
    );
    // The node should already be registered
    XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_NOT_FOUND);
    XME_ASSERT(NULL != nodeItem);
    
    *iterator = (xme_core_directory_nodeRegistryController_nodeInterfaceIterator_t*) xme_hal_mem_alloc(sizeof(xme_core_directory_nodeRegistryController_nodeInterfaceIterator_t));
    XME_CHECK(NULL != iterator, XME_STATUS_OUT_OF_RESOURCES);
        
    (*iterator)->nodeId = nodeId;
    (*iterator)->nodeItem = nodeItem;
    (*iterator)->addressType = addressType;
    (*iterator)->currentHandle = XME_HAL_TABLE_INVALID_ROW_HANDLE;
    (*iterator)->interfaceItem = NULL;

    XME_HAL_TABLE_GET_NEXT
    (
        (*iterator)->nodeItem->interfaces,
        xme_hal_table_rowHandle_t, (*iterator)->currentHandle,
        xme_com_interface_address_t, (*iterator)->interfaceItem,
        (*iterator)->interfaceItem->addressType == (*iterator)->addressType || XME_COM_INTERFACE_ADDRESS_TYPE_INVALID == (*iterator)->addressType
    );

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 13
0
xme_status_t
chromosomeGui_wp_marshaler_addConfig
(
	xme_wp_waypoint_instanceId_t* instanceId,
	xme_core_topic_t topic,
	xme_core_dataManager_dataPacketId_t inputPort,
	xme_core_dataManager_dataPacketId_t outputPort
)
{
	xme_hal_table_rowHandle_t configurationItemHandle;
	configurationItem_t* configurationItem;

	XME_CHECK
	(
		chromosomeGui_wp_marshaler_isSupported(topic),
		XME_STATUS_INVALID_PARAMETER
	);

	configurationItemHandle = XME_HAL_TABLE_ADD_ITEM(configurationTable);

	XME_CHECK
	(
		XME_HAL_TABLE_INVALID_ROW_HANDLE != configurationItemHandle,
		XME_STATUS_OUT_OF_RESOURCES
	);

	configurationItem = XME_HAL_TABLE_ITEM_FROM_HANDLE
	(
		configurationTable,
		configurationItemHandle
	);
	
	XME_ASSERT(NULL != configurationItem);

	configurationItem->topic = topic;
	configurationItem->inputPort = inputPort;
	configurationItem->outputPort = outputPort;

	// We use the row handle to identify this configuration
	*instanceId = (xme_wp_waypoint_instanceId_t)configurationItemHandle;

	return XME_STATUS_SUCCESS;
}
Exemplo n.º 14
0
//******************************************************************************//
// FIXME: Remove.
xme_status_t
xme_core_dataHandler_databaseTestProbe_setActiveDatabase
(
    xme_core_dataManager_dataPacketId_t dataStoreID,
    uint16_t databaseIndex
)
{
    xme_core_dataHandler_database_dataStore_t* dataStore;

    XME_ASSERT(NULL != xme_core_dataHandler_database);
    XME_CHECK(XME_CORE_DATAHANDLER_DATABASE_INDEX_DEFAULT != databaseIndex, XME_STATUS_INVALID_PARAMETER);

    XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_NOT_FOUND);

    XME_CHECK(databaseIndex <= dataStore->memoryRegion->numOfCopies, XME_STATUS_INVALID_CONFIGURATION);

    dataStore->activeDatabaseIndex = databaseIndex;

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 15
0
xme_status_t
xme_core_dataHandler_databaseTestProbe_startAttributeManipulation
(
    xme_core_dataManager_dataStoreID_t dataStoreID,
    uint32_t offset,
    uint32_t attributeKey
)
{
    xme_core_dataHandler_database_dataStore_t* dataStore;
    xme_core_dataHandler_database_attribute_t* attribute;
    xme_status_t status;

    XME_ASSERT(NULL != xme_core_dataHandler_database);

    // Get the data packet information. 
    XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_NOT_FOUND);
    XME_CHECK(XME_STATUS_SUCCESS == getAttribute(dataStore, attributeKey, &attribute), XME_STATUS_INVALID_PARAMETER);

    if (offset > attribute->attributeValueSize)
    {
        return XME_STATUS_INVALID_CONFIGURATION;
    }

    if (!dataStore->manipulated)
    {
        status = copyBetweenMemoryRegionCopies
            (
                dataStoreID, 
                XME_CORE_DATAHANDLER_DATABASE_INDEX_MASTER, 
                XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW
            );
        XME_CHECK(XME_STATUS_SUCCESS == status, status);

        status = reapplyManipulations(dataStore->dataStoreID);
        XME_CHECK(XME_STATUS_SUCCESS == status, status);

        dataStore->manipulated = true;
    }

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 16
0
xme_status_t
xme_core_directory_nodeRegistryController_getInterface
(
    xme_core_node_nodeId_t nodeId,
    xme_com_interface_addressType_t addressType,
    xme_com_interface_address_t** outInterfaceAddress
)
{
    xme_hal_table_rowHandle_t handle;
    xme_core_node_nodeData_t* nodeItem;
    xme_com_interface_address_t* interfaceItem;

    XME_CHECK(XME_CORE_NODE_INVALID_NODE_ID != nodeId, XME_STATUS_INVALID_PARAMETER);
    XME_CHECK(XME_COM_INTERFACE_ADDRESS_TYPE_INVALID != addressType, XME_STATUS_INVALID_PARAMETER);
    XME_CHECK(NULL != outInterfaceAddress, XME_STATUS_INVALID_PARAMETER);

    // Search for an existing item for this node
    handle = XME_HAL_TABLE_INVALID_ROW_HANDLE;
    nodeItem = NULL;
    XME_HAL_TABLE_GET_NEXT(xme_core_directory_nodeRegistryController_nodeTable, xme_hal_table_rowHandle_t, handle, xme_core_node_nodeData_t, nodeItem, nodeItem->nodeId == nodeId);

    // Return if the node is not yet registered
    XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_NOT_FOUND);
    
    // FIXME: If nodeItem is NULL, we still return XME_STATUS_SUCCESS -- is this intended?
    if (nodeItem != NULL)
    {
        // Within the node item, look for the appropriate interface
        handle = XME_HAL_TABLE_INVALID_ROW_HANDLE;
        interfaceItem = NULL;
        XME_HAL_TABLE_GET_NEXT(nodeItem->interfaces, xme_hal_table_rowHandle_t, handle, xme_com_interface_address_t, interfaceItem, interfaceItem->addressType == addressType);

        // Return if no matching interface was found
        XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle, XME_STATUS_NOT_FOUND);
        XME_ASSERT(NULL != interfaceItem);

        *outInterfaceAddress = interfaceItem;
    }

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 17
0
xme_status_t
addManipulation
(
    xme_core_dataManager_dataStoreID_t dataStoreID,
    uintptr_t address,
    uint32_t value
)
{
    xme_core_dataHandler_database_manipulationItem_t* manipulationItem = NULL;
    xme_hal_table_rowHandle_t internalHandle = XME_HAL_TABLE_INVALID_ROW_HANDLE;

    // Obtain the next element. 
    XME_HAL_TABLE_GET_NEXT
    (
        manipulationsTable,
        xme_hal_table_rowHandle_t, internalHandle, 
        xme_core_dataHandler_database_manipulationItem_t, manipulationItem, 
        (manipulationItem->dataStoreID == dataStoreID && manipulationItem->address == (uintptr_t) address)
    );

    if (XME_HAL_TABLE_INVALID_ROW_HANDLE == internalHandle)
    {
        // Create a new element. 
        internalHandle = XME_HAL_TABLE_ADD_ITEM(manipulationsTable);
        XME_CHECK(XME_HAL_TABLE_INVALID_ROW_HANDLE != internalHandle, XME_STATUS_OUT_OF_RESOURCES);
        manipulationItem = XME_HAL_TABLE_ITEM_FROM_HANDLE(manipulationsTable, internalHandle);
        XME_ASSERT(NULL != manipulationItem);
        manipulationItem->dataStoreID = dataStoreID;
        manipulationItem->address = address;
        manipulationItem->value = value;
    }
    else
    {
        // Use existing element. 
        manipulationItem->value = value;
    }
    return XME_STATUS_SUCCESS;
}
Exemplo n.º 18
0
xme_status_t
copyBetweenMemoryRegionCopies
(
    xme_core_dataManager_dataStoreID_t dataStoreID,
    uint16_t sourceDatabaseIndex,
    uint16_t targetDatabaseIndex
)
{
    uintptr_t sourceDataAddress;
    uintptr_t sinkDataAddress;
    xme_core_dataHandler_database_dataStore_t* dataStore;
    uint32_t transferSizeInBytes;
    uint32_t totalOffset;
    void* returnAddress;
    void* sourceDatabaseAddress;
    void* sinkDatabaseAddress;

    XME_ASSERT(NULL != xme_core_dataHandler_database);

    // Get the data packet information.
    XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE);

    // Calculate the total offsets to add.
    totalOffset = dataStore->topicOffset;

    // Calculate the position in the queue for the source and sink address.
    if (dataStore->queueSize > 1)
    {
        totalOffset += dataStore->dataStoreSize * dataStore->currentCBWritePosition;
    }

    // Get the number of bytes to use in the transfer operation.
    transferSizeInBytes = getBytesToCopy(dataStore->topicSize, dataStore->topicSize, 0U);

    // Get source database address from the source database copy.
    sourceDatabaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, sourceDatabaseIndex - 1U);

    // Get source database address from the source database copy.
    sinkDatabaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, targetDatabaseIndex - 1U); 

    // Check that the database addresses contain correct values.
    XME_CHECK(0U != sourceDatabaseAddress, XME_STATUS_NOT_FOUND);
    XME_CHECK(0U != sinkDatabaseAddress, XME_STATUS_NOT_FOUND);

    if (dataStore->dataAvailable)
    {
        // Add the offset corresponding to the source and sink addresses.
        sourceDataAddress = ((uintptr_t) sourceDatabaseAddress + totalOffset);
        sinkDataAddress = ((uintptr_t) sinkDatabaseAddress + totalOffset);

        // Do the transfer for the current copy of the database->
        returnAddress = xme_hal_mem_copy((void*) sinkDataAddress, (void*) sourceDataAddress, transferSizeInBytes);
        XME_CHECK(returnAddress == (void*) sinkDataAddress, XME_STATUS_INTERNAL_ERROR);
    }

    // Try the transfer for all attributes as well.
    XME_HAL_SINGLYLINKEDLIST_ITERATE_BEGIN(dataStore->attributes, xme_core_dataHandler_database_attribute_t, attribute);
    {
        if (attribute->dataAvailable == true)
        {
            // If the attribute exists in the target data packet.
            uint32_t totalAttributeOffset;
            uintptr_t sourceAttributeAddress;
            uintptr_t sinkAttributeAddress;
            uint32_t totalAttributeSizeInBytes;

            // Calculate the total offsets to add.
            totalAttributeOffset = attribute->attributeOffset;

            // Calculate the position in the queue for the source and sink address.
            if (dataStore->queueSize > 1)
            {
                totalAttributeOffset += dataStore->dataStoreSize * dataStore->currentCBWritePosition;
            }

            // Get trasnfer bytes to copy.
            totalAttributeSizeInBytes = getBytesToCopy(attribute->attributeValueSize, attribute->attributeValueSize, 0U);

            // Add the offset corresponding to the source and sink addresses.
            sourceAttributeAddress = ((uintptr_t) sourceDatabaseAddress + totalAttributeOffset);
            sinkAttributeAddress = ((uintptr_t) sinkDatabaseAddress + totalAttributeOffset);

            // Do the transfer for the current copy of the database->
            returnAddress = xme_hal_mem_copy((void*) sinkAttributeAddress, (void*) sourceAttributeAddress, totalAttributeSizeInBytes);
            XME_CHECK(returnAddress == (void*) sinkAttributeAddress, XME_STATUS_INTERNAL_ERROR);
        }
    }
    XME_HAL_SINGLYLINKEDLIST_ITERATE_END();

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 19
0
xme_status_t
xme_core_dataHandler_databaseTestProbe_readAttribute
(
    xme_core_dataHandler_database_index_t databaseIndex,
    xme_core_dataManager_dataPacketId_t dataStoreID,
    uint32_t attributeKey,
    uint32_t offsetInBytes,
    void* const targetBuffer,
    size_t targetBufferSizeInBytes,
    uint32_t* const readBytes
)
{
    uintptr_t attributeAddress;
    size_t attributeSizeInBytes;
    xme_core_dataHandler_database_dataStore_t* dataStore;
    xme_core_dataHandler_database_attribute_t* attribute;
    uint32_t totalOffset;
    void* returnAddress;
    void* databaseAddress;

    XME_ASSERT(NULL != xme_core_dataHandler_database);
    XME_ASSERT(NULL != readBytes);

    *readBytes = 0U;

    // Obtain first the data packet and then the attribute.  
    XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE);
    XME_CHECK(XME_STATUS_SUCCESS == getAttribute(dataStore, attributeKey, &attribute), XME_STATUS_INVALID_PARAMETER);

    XME_CHECK(databaseIndex <= dataStore->memoryRegion->numOfCopies, XME_STATUS_INVALID_CONFIGURATION);

    XME_CHECK(attribute->dataAvailable, XME_STATUS_NO_SUCH_VALUE);

    // Return an error if an attempt is made to read outside the bounds of the data packet
    XME_CHECK(offsetInBytes < attribute->attributeValueSize, XME_STATUS_INVALID_PARAMETER);

    // Calculate the total offset to add.
    totalOffset = attribute->attributeOffset + offsetInBytes;

    // Add queue write position. 
    if (dataStore->queueSize > 1)
    {
        totalOffset += (dataStore->dataStoreSize * dataStore->currentCBReadPosition);
    }

    // Get the number of bytes to use in the read operation.
    attributeSizeInBytes = getBytesToCopy(attribute->attributeValueSize, targetBufferSizeInBytes, offsetInBytes);

    if (((xme_core_dataHandler_database_index_t)XME_CORE_DATAHANDLER_DATABASE_INDEX_DEFAULT) == databaseIndex)
    {
        // Get database address from the active database in the data packet. 
        databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, dataStore->activeDatabaseIndex - 1U);
    }
    else
    {
        // Get database address from the provided database index. 
        databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, databaseIndex - 1U);
    }

    // Check that the database address and size contains correct values. 
    XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND);

    // Add the offset.
    attributeAddress = ((uintptr_t) databaseAddress + totalOffset);

    if (targetBufferSizeInBytes > attributeSizeInBytes)
    {
        uintptr_t bufferToCopy;

        bufferToCopy = ((uintptr_t) targetBuffer + (targetBufferSizeInBytes - attributeSizeInBytes));
        returnAddress = xme_hal_mem_copy(targetBuffer, (void*) bufferToCopy, attributeSizeInBytes);
        XME_CHECK(returnAddress == (void*) targetBuffer, XME_STATUS_INTERNAL_ERROR);
    }
    else
    {
        // Do the read operation
        returnAddress = xme_hal_mem_copy(targetBuffer, (void*) attributeAddress, attributeSizeInBytes);
        XME_CHECK(returnAddress == (void*) targetBuffer, XME_STATUS_INTERNAL_ERROR);
    }

    // Set the effectively read bytes. 
    *readBytes = attributeSizeInBytes;

    // Check that the target buffer is not null-valued. 
    XME_CHECK(NULL != targetBuffer, XME_STATUS_INVALID_CONFIGURATION);

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 20
0
xme_status_t
xme_core_dataHandler_databaseTestProbe_readData
(
    xme_core_dataHandler_database_index_t databaseIndex,
    xme_core_dataManager_dataPacketId_t dataStoreID,
    uint32_t offsetInBytes,
    void* const targetBuffer,
    size_t targetBufferSizeInBytes,
    uint32_t* const readBytes
)
{
    uintptr_t dataAddress;
    size_t dataSizeInBytes;
    xme_core_dataHandler_database_dataStore_t* dataStore;
    uint32_t totalOffset;
    void* returnAddress;
    void* databaseAddress;

    XME_ASSERT(NULL != xme_core_dataHandler_database);

    XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE);

    XME_CHECK(databaseIndex <= dataStore->memoryRegion->numOfCopies, XME_STATUS_INVALID_CONFIGURATION);

    if (!dataStore->dataAvailable)
    {
        *readBytes = 0U;
        return XME_STATUS_NO_SUCH_VALUE;
    }

    if (offsetInBytes >= dataStore->topicSize)
    {
        // We can not read outside the limit of the data packet. An error is returned. 
        *readBytes = 0U;
        return XME_STATUS_INVALID_PARAMETER;
    }

    // Calculate the total offset to add.
    totalOffset = dataStore->topicOffset + offsetInBytes;

    // Add queue write position. 
    if (dataStore->queueSize > 1)
    {
        totalOffset += (dataStore->dataStoreSize * dataStore->currentCBReadPosition);
    }

    // Get the number of bytes to use in the read operation.
    dataSizeInBytes = getBytesToCopy(dataStore->topicSize, targetBufferSizeInBytes, offsetInBytes);

    if (((xme_core_dataHandler_database_index_t)XME_CORE_DATAHANDLER_DATABASE_INDEX_DEFAULT) == databaseIndex)
    {
        // Get database address from the active database in the data packet. 
        databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, dataStore->activeDatabaseIndex - 1U);
    }
    else
    {
        // Get database address from the provided database index. 
        databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, databaseIndex - 1U);
    }

    // Check that the database address and size contains correct values. 
    XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND);

    // Add the offset.
    dataAddress = ((uintptr_t) databaseAddress + totalOffset);

    if (targetBufferSizeInBytes > dataSizeInBytes)
    {
        uintptr_t bufferToCopy;

        bufferToCopy = ((uintptr_t) targetBuffer + (targetBufferSizeInBytes - dataSizeInBytes));
        returnAddress = xme_hal_mem_copy((void*) bufferToCopy, (void*) dataAddress, dataSizeInBytes);
        XME_CHECK(returnAddress == (void*) bufferToCopy, XME_STATUS_INTERNAL_ERROR);
    }
    else
    {
        // Do the read operation
        returnAddress = xme_hal_mem_copy(targetBuffer, (void*) dataAddress, dataSizeInBytes);
        XME_CHECK(returnAddress == (void*) targetBuffer, XME_STATUS_INTERNAL_ERROR);
    }

    // Set the effectively read bytes. 
    *readBytes = dataSizeInBytes;

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 21
0
xme_status_t
xme_core_dataHandler_databaseTestProbe_writeAttribute
(
    uint16_t databaseIndex,
    xme_core_dataManager_dataPacketId_t dataStoreID,
    uint32_t attributeKey,
    uint32_t offsetInBytes,
    const void* const sourceBuffer,
    size_t sourceBufferSizeInBytes,
    uint32_t* const writtenBytes
)
{
    uintptr_t attributeAddress;
    size_t attributeSizeInBytes;
    xme_core_dataHandler_database_dataStore_t* dataStore;
    xme_core_dataHandler_database_attribute_t* attribute;
    uint32_t totalOffset;
    void* returnAddress;
    void* databaseAddress;

    XME_ASSERT(NULL != xme_core_dataHandler_database);

    // Obtain first the data packet and then the attribute.  
    XME_CHECK(XME_STATUS_SUCCESS == getDataStore(dataStoreID, &dataStore), XME_STATUS_INVALID_HANDLE);

    XME_CHECK(XME_STATUS_SUCCESS == getAttribute(dataStore, attributeKey, &attribute), XME_STATUS_INVALID_PARAMETER);

    XME_CHECK(databaseIndex <= dataStore->memoryRegion->numOfCopies, XME_STATUS_INVALID_CONFIGURATION);

    if (offsetInBytes >= attribute->attributeValueSize)
    {
        // We can not write outside the limit of the data packet. An error is returned. 
        *writtenBytes = 0U;
        return XME_STATUS_INVALID_PARAMETER;
    }

    // Calculate the total offset to add.
    totalOffset = attribute->attributeOffset + offsetInBytes;

    // Add queue write position. 
    if (dataStore->queueSize > 1)
    {
        totalOffset += (dataStore->dataStoreSize * dataStore->currentCBWritePosition);
    }

    // Get the number of bytes to use in the write operation.
    attributeSizeInBytes = getBytesToCopy(attribute->attributeValueSize, sourceBufferSizeInBytes, offsetInBytes);

    XME_CHECK(XME_CORE_DATAHANDLER_DATABASE_INDEX_DEFAULT != databaseIndex, XME_STATUS_INVALID_PARAMETER);

    // Get database address. 
    databaseAddress = getAddressFromMemoryCopy(dataStore->memoryRegion, databaseIndex - 1U);

    // Check that the data address and size contains correct values. 
    XME_CHECK(0U != databaseAddress, XME_STATUS_NOT_FOUND);

    // Add the offset.
    attributeAddress = ((uintptr_t) databaseAddress + totalOffset);

    // Do the copy operation
    returnAddress = xme_hal_mem_copy((void*) attributeAddress, sourceBuffer, attributeSizeInBytes);
    XME_CHECK(returnAddress == (void*) attributeAddress, XME_STATUS_INTERNAL_ERROR);

    // Set the effectively written bytes. 
    *writtenBytes = attributeSizeInBytes;

    // Check that the target buffer is not null-valued. 
    XME_CHECK(NULL != sourceBuffer, XME_STATUS_INVALID_CONFIGURATION);

    // Set attribute availability to true. 
    XME_CHECK(XME_STATUS_SUCCESS == setAttributeAvailability(attribute, true), XME_STATUS_INVALID_CONFIGURATION);

    if (XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW == databaseIndex)
    {
        // Add the manipulation. 
        uint32_t* value = (uint32_t*) sourceBuffer;
        xme_status_t status = addManipulation(dataStoreID, attributeAddress, *value);
        XME_CHECK(XME_STATUS_SUCCESS == status, XME_STATUS_INVALID_CONFIGURATION);

        // Activate the shadow database. 
        dataStore->activeDatabaseIndex = XME_CORE_DATAHANDLER_DATABASE_INDEX_SHADOW;
    }

    return XME_STATUS_SUCCESS;
}