Exemple #1
0
u32 BM_ParseRouteReplace(LPBIFSDEC codec, BitStream *bs, Chain *com_list)
{
	M4Err e;
	SGCommand *com;
	u32 RouteID, numBits, ind, node_id, fromID, toID;
	LPROUTE r;
	SFNode *OutNode, *InNode;

	RouteID = 1+BS_ReadInt(bs, codec->info->config.RouteIDBits);
	
	r = SG_FindRoute(codec->current_graph, RouteID);

	/*origin*/
	node_id = 1 + BS_ReadInt(bs, codec->info->config.NodeIDBits);
	OutNode = BIFS_FindNode(codec, node_id);
	if (!OutNode) return M4NonCompliantBitStream;
	numBits = GetNumBits(Node_GetNumFields(OutNode, FCM_OUT) - 1);
	ind = BS_ReadInt(bs, numBits);
	e = Node_GetFieldIndex(OutNode, ind, FCM_OUT, &fromID);
	if (e) return e;

	/*target*/
	node_id = 1 + BS_ReadInt(bs, codec->info->config.NodeIDBits);
	InNode = BIFS_FindNode(codec, node_id);
	if (!InNode) return M4NonCompliantBitStream;
	numBits = GetNumBits(Node_GetNumFields(InNode, FCM_IN) - 1);
	ind = BS_ReadInt(bs, numBits);
	e = Node_GetFieldIndex(InNode, ind, FCM_IN, &toID);
	if (e) return e;

	com = SG_NewCommand(codec->current_graph, SG_RouteReplace);
	com->RouteID = RouteID;
	com->fromNodeID = Node_GetID(OutNode);
	com->fromFieldIndex = fromID;
	com->toNodeID = Node_GetID(InNode);
	com->toFieldIndex = toID;
	ChainAddEntry(com_list, com);
	return codec->LastError;
}
Exemple #2
0
void InitTimeSensor(LPSCENERENDER sr, SFNode *node)
{
	TimeSensorStack *st = malloc(sizeof(TimeSensorStack));
	memset(st, 0, sizeof(TimeSensorStack));
	st->time_handle.UpdateTimeNode = UpdateTimeSensor;
	st->time_handle.obj = node;
	st->store_info = 1;
	st->compositor = sr;

	Node_SetPrivate(node, st);
	Node_SetPreDestroyFunction(node, DestroyTimeSensor);
	/*time sensor needs to be run only if def'ed, otherwise it doesn't impact scene*/
	if (Node_GetID(node)) SR_RegisterTimeNode(sr, &st->time_handle);
}
Exemple #3
0
struct node_t *Nodes_GetNodeFromID(uint8_t id)
{
    sc_assert(module.number_of_nodes <= ElementsIn(module.nodes));

    for (size_t i = 0; i < module.number_of_nodes; ++i)
    {
        if (Node_GetID(module.nodes[i]) == id)
        {
            return module.nodes[i];
        }
    }

    return NULL;
}
bool PacketHandler_HandleReadingPacket(packet_frame_type *packet_p)
{
    sc_assert(packet_p != NULL);

    struct node_t *node_p = Nodes_GetNodeFromID(packet_p->header.source);

    if (node_p != NULL)
    {
        DEBUG("Reading packet from 0x%02x\r\n", Node_GetID(node_p));

        Node_ReportActivity(node_p);
        Node_SetRSSI(node_p, packet_p->header.rssi);
        Node_Update(node_p, packet_p->content.data, (size_t)packet_p->content.size);
        SendAck(Node_GetID(node_p));

        return true;
    }
    else
    {
        WARNING("Received packet from unknown node: %x", packet_p->header.source);
        return false;
    }
}