/home/dko/projects/mobilec/tags/MobileC-v1.10.2/MobileC-v1.10.2/src/include/agent.h

Go to the documentation of this file.
00001 /* SVN FILE INFO
00002  * $Revision: 207 $ : Last Committed Revision
00003  * $Date: 2008-07-11 17:55:19 -0700 (Fri, 11 Jul 2008) $ : Last Committed Date */
00004 /*[
00005  * Copyright (c) 2007 Integration Engineering Laboratory
00006                       University of California, Davis
00007  *
00008  * Permission to use, copy, and distribute this software and its
00009  * documentation for any purpose with or without fee is hereby granted,
00010  * provided that the above copyright notice appear in all copies and
00011  * that both that copyright notice and this permission notice appear
00012  * in supporting documentation.
00013  *
00014  * Permission to modify the software is granted, but not the right to
00015  * distribute the complete modified source code.  Modifications are to
00016  * be distributed as patches to the released version.  Permission to
00017  * distribute binaries produced by compiling modified sources is granted,
00018  * provided you
00019  *   1. distribute the corresponding source modifications from the
00020  *    released version in the form of a patch file along with the binaries,
00021  *   2. add special version identification to distinguish your version
00022  *    in addition to the base release version number,
00023  *   3. provide your name and address as the primary contact for the
00024  *    support of your modified version, and
00025  *   4. retain our contact information in regard to use of the base
00026  *    software.
00027  * Permission to distribute the released version of the source code along
00028  * with corresponding source modifications in the form of a patch file is
00029  * granted with same provisions 2 through 4 for binary distributions.
00030  *
00031  * This software is provided "as is" without express or implied warranty
00032  * to the extent permitted by applicable law.
00033 ]*/
00034 
00035 #ifndef _AGENT_H_
00036 #define _AGENT_H_
00037 
00038 #include "agent_datastate.h"
00039 #include "agent_task.h"
00040 #include "libmc.h"
00041 #include "message.h"
00042 #include "macros.h"
00043 #include "data_structures.h"
00044 #include "agent_mailbox.h"
00045 
00046 struct mc_platform_s;
00047 
00048 struct agent_s {
00049 
00050   /* basic id numbers to determine agent characteristics */
00051   u_long id;
00052   char* name;
00053   u_long connect_id;
00054 #ifndef _WIN32
00055   time_t arrival_time;
00056 #else
00057   SYSTEMTIME arrival_time;
00058 #endif
00059 
00060   char *owner;
00061   char *home;
00062   int home_port;
00063 
00064   int orphan; /* If an agent is an 'orphan', it means it is not attached to an
00065                  agency. */
00066 
00067   /* primary agent data */
00068   agent_datastate_p datastate;  
00069   enum MC_AgentType_e agent_type; 
00070   enum MC_AgentStatus_e agent_status;
00071 
00072   int return_data;
00073 
00074   /* threading variables */
00075   ChInterp_t agent_interp;
00076   /* run_lock should be locked whenever the interpreter is running
00077    * to prevent simultaneous runs. */
00078   MUTEX_T *run_lock;
00079 
00080 #ifndef _WIN32
00081   int agent_thread_id; 
00082 #else
00083   DWORD agent_thread_id;
00084 #endif
00085   THREAD_T *agent_thread;
00086 
00087   /* Agent Mailbox */
00088   agent_mailbox_p mailbox;
00089 
00090   /* Agent Flags */
00091   int agent_pipe_active;
00092   int agent_ready_to_send;
00093   int agent_pipe_ready_to_read;
00094   int agent_script_ready;
00095   int agent_persistent;
00096 
00097   struct mc_platform_s *mc_platform;
00098 
00099   MUTEX_T* lock;
00100 };
00101 #ifndef AGENT_T
00102 #define AGENT_T
00103 typedef struct agent_s agent_t;
00104 typedef agent_t* MCAgent_t;
00105 typedef agent_t* agent_p;
00106 #endif
00107 
00108 int 
00109 agent_AddPersistentVariable(agent_p agent, int task_num, const char* var_name);
00110 
00111 agent_p
00112 agent_New(void);
00113 
00114 agent_p
00115 agent_Copy(const agent_p agent);
00116 
00117   int
00118 agent_Destroy(agent_p agent);
00119 
00120 agent_p
00121 agent_Initialize(
00122     struct mc_platform_s* mc_platform,
00123     message_p message,
00124     int id);
00125 
00126 int 
00127 agent_Destroy(agent_p agent);
00128 
00129 void agent_RunChScript(MCAgent_t agent, struct mc_platform_s* global);
00130 #ifndef _WIN32
00131 void * agent_RunChScriptThread(void * agent);
00132 #else
00133 DWORD WINAPI agent_RunChScriptThread(void * ChAgent);
00134 #endif
00135 
00136 #endif 

Generated on Fri Jul 11 17:59:44 2008 for Mobile-C by  doxygen 1.5.4