Revision 1bfc6b25 src/urt_node.c

View differences:

src/urt_node.c
37 37
/* LOCAL VARIABLES                                                            */
38 38
/******************************************************************************/
39 39

  
40
urt_node_t localNode; //TODO:Correct?
40
urt_node_t localNode; //TODO
41 41

  
42 42
/******************************************************************************/
43 43
/* LOCAL FUNCTIONS                                                            */
......
50 50
 */
51 51
void _main(void* arg)
52 52
{
53
    //TODO: Register to core event
54
    if (localNode.setupcallback != NULL)
53
  urt_osEventMask_t mask;
54
  urt_osEventFlags_t flag;   //TODO: flag from core here
55
  urtEventRegister(core._evtSource, &localNode.listener, mask, flag);
56
  if (localNode.setupcallback != NULL)
57
  {
58
    mask = localNode.setupcallback(&localNode, arg);
59
    if (mask /*TODO: check single bits from mask to find out if bit for core is 1 */)
55 60
    {
56
        // urt_osEventMask_t mask = localNode.setupcallback(localNode, arg);
57
        // TODOs
61
        urtCoreStopNodes(URT_STATUS_NODE_INVALEVTMASK);
58 62
    }
59
    else
60
    {
61
        //TODO: act as if setupcallback returned 0xF..F
62
    }
63
    if (core._status == URT_STATUS_OK)
63
  }
64
  else
65
  {
66
     mask = 0xFFFFFFFF;
67
  }
68

  
69
  if (core._status == URT_STATUS_OK)
70
  {
71
    urtCoreSynchronizeNodes(&localNode);
72
  }
73

  
74
  bool terminated = false;
75
  if (terminated /*TODO: replace with function*/)
76
  {
77
    urt_osEventMask_t temp = urtEventWait(mask, URT_EVENT_WAIT_ONE, URT_DELAY_INFINITE);
78
    if (temp /*TODO: check single bits from mask to find out if bit for core is 1 */)
64 79
    {
65
        //TODO: Suspend all child threads
66
        urtCoreSynchronizeNodes(&localNode);
67
        //TODO: Resume all child threads
80
      localNode.loopcallback(&localNode, mask, arg);
81
      #if (URT_CFG_PUBSUB_PROFILING || URT_CFG_RPC_PROFILING)
82
        localNode.loops++;
83
      #endif /* URT_CFG_PUBSUB_PROFILING || URT_CFG_RPC_PROFILING */
84
      if (mask /*TODO: check single bits from mask to find out if bit for core is 1 */)
85
      {
86
        urtCoreStopNodes(URT_STATUS_NODE_INVALEVTMASK);
87
      }
68 88
    }
69
    //TODOs
70
    return;
89
  }
90

  
91
  if (localNode.shutdowncallback)
92
  {
93
    localNode.shutdowncallback(&localNode, urtCoreGetStatus(), arg);
94
  }
95
  urtEventUnregister(core._evtSource, &localNode.listener);
96
  urt_osThread_t* threadToTerminate = localNode.thread;
97
  urt_osThread_t* threadToTerminateChild;
98
  while (threadToTerminate != NULL)
99
  {
100
    threadToTerminateChild = threadToTerminate->children;
101
    urtThreadTerminate(&threadToTerminate, URT_THREAD_TERMINATE_REQUEST);
102
    threadToTerminate = threadToTerminateChild;
103
  }
104
  urtThreadExit();
105
  return;
71 106
}
72 107

  
73 108
/******************************************************************************/
......
85 120
 *                         Must be NULL if no setup callback is specified.
86 121
 *                         May be NULL if the specified setup callback does not expect parameters.
87 122
 * @param[in] loopcallback  Callback function to be executed in a loop.
88
 *                          Must not be NULL.
89 123
 * @param[in] loopparams  Parameters for the loop callback function.
90 124
 *                        May be NULL if the specified loop callback does not expect parameters.
91 125
 * @param[in] shutdowncallback  Callback function to be executed during shutdown.
......
100 134
{
101 135
  urtDebugAssert(node != NULL);
102 136
  urtDebugAssert(thread != NULL);
103
  //TODO: Setupcallback
104 137
  if (setupcallback == NULL)
105 138
    urtDebugAssert(setupparams == NULL);
106
  urtDebugAssert(loopcallback != NULL);
107
  //urtDebugAssert(/*loopparams*/);
108
  //urtDebugAssert(shutdowncallback);
109
  //urtDebugAssert(shutdownparams);
110 139

  
111 140
  node->next = NULL;
112 141
  node->thread = thread;

Also available in: Unified diff