src/hcode/tick.c File Reference

#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <string.h>
#include <event.h>
#include "glue_types.h"
#include "mux_tree.h"
#include "mech.h"
#include "autopilot.h"
#include "debug.h"

Include dependency graph for tick.c:

Go to the source code of this file.

Functions

void GoThruTree (Tree tree, int(*func)(Node *))
void heartbeat_run (int fd, short event, void *arg)
void heartbeat_init ()
void heartbeat_stop ()
void mech_heartbeat (MECH *)
void auto_heartbeat (AUTO *)
int heartbeat_dispatch (Node *node)

Variables

static struct event heartbeat_ev
static struct timeval heartbeat_tv = { 1, 0 }
static int heartbeat_running = 0
unsigned int global_tick = 0
Tree xcode_tree


Function Documentation

void auto_heartbeat ( AUTO  ) 

Definition at line 966 of file autopilot_core.c.

References auto_gun_event(), AUTO_PROFILE_TICK, auto_sensor_event(), auto_update_profile_event(), global_tick, AUTO::mymech, and AUTO::weaplist.

Referenced by heartbeat_dispatch().

00966                                      {
00967     if(!autopilot->mymech) return;
00968     auto_sensor_event(autopilot);
00969     if(autopilot->weaplist == NULL || global_tick % AUTO_PROFILE_TICK == 0)  
00970         auto_update_profile_event(autopilot);
00971     auto_gun_event(autopilot);
00972 }

void GoThruTree ( Tree  tree,
int(*)(Node *)  func 
)

Definition at line 171 of file mux_tree.c.

00172 {
00173     tree_trav(&tree, func);
00174 }

int heartbeat_dispatch ( Node node  ) 

Definition at line 51 of file tick.c.

References auto_heartbeat(), GTYPE_AUTO, GTYPE_MECH, mech_heartbeat(), NodeData, and NodeType.

Referenced by heartbeat_run().

00051                                    {
00052     switch(NodeType(node)) {
00053         case GTYPE_MECH:
00054             mech_heartbeat((MECH *)NodeData(node));
00055             break;
00056         case GTYPE_AUTO:
00057             auto_heartbeat((AUTO *)NodeData(node));
00058             break;
00059     }
00060     return 1;
00061 }

void heartbeat_init (  ) 

Definition at line 33 of file tick.c.

References dprintk, heartbeat_ev, heartbeat_run(), heartbeat_running, and heartbeat_tv.

Referenced by load_xcode().

00033                       {
00034     if(heartbeat_running) return;
00035     dprintk("hearbeat initialized, %ds timeout.", (int)heartbeat_tv.tv_sec);
00036     evtimer_set(&heartbeat_ev, heartbeat_run, NULL);
00037     evtimer_add(&heartbeat_ev, &heartbeat_tv);
00038     heartbeat_running = 1;
00039 }

void heartbeat_run ( int  fd,
short  event,
void *  arg 
)

Definition at line 63 of file tick.c.

References global_tick, GoThruTree(), heartbeat_dispatch(), heartbeat_ev, heartbeat_tv, and xcode_tree.

Referenced by heartbeat_init().

00063                                                    {
00064     evtimer_add(&heartbeat_ev, &heartbeat_tv);
00065     GoThruTree(xcode_tree, heartbeat_dispatch);
00066     global_tick++;
00067 }

void heartbeat_stop (  ) 

Definition at line 41 of file tick.c.

References dprintk, heartbeat_ev, and heartbeat_running.

00041                       {
00042     if(!heartbeat_running) return;
00043     evtimer_del(&heartbeat_ev);
00044     dprintk("heartbeat stopped.\n");
00045     heartbeat_running = 0;
00046 }

void mech_heartbeat ( MECH  ) 

Definition at line 25 of file mech.events.c.

References UpdateRecycling.

Referenced by heartbeat_dispatch().

00025                                 {
00026     UpdateRecycling(mech);
00027     return;
00028 }


Variable Documentation

unsigned int global_tick = 0

Definition at line 27 of file tick.c.

Referenced by auto_heartbeat(), and heartbeat_run().

struct event heartbeat_ev [static]

Definition at line 24 of file tick.c.

Referenced by heartbeat_init(), heartbeat_run(), and heartbeat_stop().

int heartbeat_running = 0 [static]

Definition at line 26 of file tick.c.

Referenced by heartbeat_init(), and heartbeat_stop().

struct timeval heartbeat_tv = { 1, 0 } [static]

Definition at line 25 of file tick.c.

Referenced by heartbeat_init(), and heartbeat_run().

Tree xcode_tree

Definition at line 98 of file glue.c.


Generated on Mon May 28 04:25:45 2007 for BattletechMUX by  doxygen 1.4.7