00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 #ifndef _MOBILEC_H_
00118 #define _MOBILEC_H_
00119
00120 #ifdef WIN32
00121 #ifdef _MC_DLL
00122
00123 #define EXPORTMC _declspec(dllexport)
00124 #else
00125
00126 #define EXPORTMC
00127 #endif
00128 #else
00129
00130 #define EXPORTMC
00131 #endif
00132
00133
00134
00135 #define MC_Wait(arg1) \
00136 MC_MainLoop(arg1)
00137
00138 #include <embedch.h>
00139 #ifdef __cplusplus
00140 extern "C" {
00141 #endif
00142
00143 #ifndef _ERROR_CODE_E_
00144 #define _ERROR_CODE_E_
00145
00146
00147
00148
00149 typedef enum error_code_e {
00150 MC_SUCCESS = 0,
00151 MC_ERR,
00152 MC_ERR_CONNECT,
00153 MC_ERR_PARSE,
00154 MC_ERR_EMPTY,
00155 MC_ERR_INVALID,
00156 MC_ERR_INVALID_ARGS,
00157 MC_ERR_NOT_FOUND,
00158 MC_ERR_MEMORY,
00159 MC_ERR_SEND,
00160 MC_WARN_DUPLICATE
00161 } error_code_t;
00162 #endif
00163
00167 enum MC_ThreadIndex_e{
00168 MC_THREAD_DF=0,
00169 MC_THREAD_AMS,
00170 MC_THREAD_ACC,
00171 MC_THREAD_CP,
00172 MC_THREAD_AGENT,
00173 MC_THREAD_ALL };
00174
00175
00179 typedef enum MC_SteerCommand_e {
00180 MC_RUN = 0,
00181 MC_SUSPEND,
00182 MC_RESTART,
00183 MC_STOP
00184 } MC_SteerCommand_t;
00185
00194 enum MC_Signal_e{
00195 MC_NO_SIGNAL =0x00,
00196 MC_RECV_CONNECTION=0x01,
00197 MC_RECV_MESSAGE =0x02,
00198 MC_RECV_AGENT =0x04,
00199 MC_RECV_RETURN =0x08,
00200 MC_EXEC_AGENT =0x0F,
00201 MC_ALL_SIGNALS =0x10
00202 };
00203
00207 typedef struct agency_s {
00208 int client;
00209 int server;
00210 char *hostName;
00211 char *filename;
00212 int portno;
00213 int portnoc;
00214 struct mc_platform_s* mc_platform;
00215 int default_agentstatus;
00216 int threads;
00217 int enable_security;
00218 int stack_size[MC_THREAD_ALL];
00219 error_code_t last_error;
00220 } agency_t;
00221 typedef agency_t* agency_p;
00222 typedef agency_p MCAgency_t;
00223
00227 typedef struct MCAgencyOptions_s{
00228 int threads;
00229 int default_agent_status;
00230 int modified;
00231 int enable_security;
00233
00234 int stack_size[MC_THREAD_ALL];
00235 } MCAgencyOptions_t;
00236
00237 #ifndef AGENT_T
00238 #define AGENT_T
00239 typedef struct agent_s agent_t;
00240 typedef agent_t* MCAgent_t;
00241 typedef agent_t* agent_p;
00242 #endif
00243
00244 enum MC_AgentType_e{ MC_NONE = -1, MC_REMOTE_AGENT = 0, MC_LOCAL_AGENT, MC_RETURN_AGENT };
00245
00249 enum MC_AgentStatus_e{
00250 MC_WAIT_CH,
00251 MC_WAIT_MESSGSEND,
00252 MC_AGENT_ACTIVE,
00253 MC_AGENT_NEUTRAL,
00254 MC_AGENT_SUSPENDED,
00255 MC_WAIT_FINISHED
00256 };
00257
00258 struct fipa_acl_message_s;
00259
00267 int
00268 MC_AclDestroy(struct fipa_acl_message_s* message);
00269
00275 EXPORTMC extern struct fipa_acl_message_s*
00276 MC_AclNew(void);
00277
00286 EXPORTMC extern int MC_AclPost(MCAgent_t agent, struct fipa_acl_message_s* message);
00287
00298 EXPORTMC extern struct fipa_acl_message_s*
00299 MC_AclReply(struct fipa_acl_message_s* acl_message);
00300
00308 EXPORTMC extern struct fipa_acl_message_s* MC_AclRetrieve(MCAgent_t agent);
00309
00318 EXPORTMC extern int MC_AclSend(MCAgency_t attr, struct fipa_acl_message_s* acl);
00319
00327 EXPORTMC extern struct fipa_acl_message_s* MC_AclWaitRetrieve(MCAgent_t agent);
00328
00337 EXPORTMC extern int MC_AddAgent(
00338 MCAgency_t attr,
00339 MCAgent_t agent);
00340
00350 EXPORTMC extern int MC_BarrierDelete(MCAgency_t attr, int id);
00351
00367 EXPORTMC extern int MC_BarrierInit(MCAgency_t attr, int id, int num_procs);
00368
00377 EXPORTMC extern int MC_ChInitializeOptions(MCAgency_t attr, ChOptions_t *options);
00378
00395 EXPORTMC extern int MC_CallAgentFunc(
00396 MCAgent_t agent,
00397 const char* funcName,
00398 void* returnVal,
00399 void* varg
00400 );
00401
00402 MCAgent_t
00403 MC_ComposeAgent(
00404 const char* name,
00405 const char* home,
00406 const char* owner,
00407 const char* code,
00408 const char* return_var_name,
00409 const char* server,
00410 int persistent
00411 );
00412
00423 EXPORTMC extern int MC_CondBroadcast(MCAgency_t attr, int id);
00424
00440 EXPORTMC extern int MC_CondSignal(MCAgency_t attr, int id);
00441
00452 EXPORTMC extern int MC_CondReset(MCAgency_t attr, int id);
00453
00467 EXPORTMC extern int MC_CondWait(MCAgency_t attr, int id);
00468
00478 int MC_CopyAgent(MCAgent_t* agent_out, const MCAgent_t agent_in);
00479
00488 EXPORTMC extern int MC_DeleteAgent(MCAgent_t agent);
00489
00500 EXPORTMC extern int MC_End(MCAgency_t attr);
00501
00512 int MC_DestroyServiceSearchResult(
00513 char** agentName,
00514 char** serviceName,
00515 int* agentID,
00516 int numResult);
00517
00518
00529 EXPORTMC extern MCAgent_t MC_FindAgentByName(MCAgency_t attr, const char *name);
00530
00539 EXPORTMC extern MCAgent_t MC_FindAgentByID(MCAgency_t attr, int ID);
00540
00549 EXPORTMC extern void* MC_GetAgentExecEngine(MCAgent_t agent);
00550
00554 EXPORTMC extern int MC_GetAgentID(MCAgent_t agent);
00555
00556
00557
00558
00559
00560
00561 EXPORTMC extern char* MC_GetAgentName(MCAgent_t agent);
00562
00568 EXPORTMC extern int MC_GetAgentNumTasks(MCAgent_t agent);
00569
00586 EXPORTMC extern int MC_GetAgentReturnData(
00587 MCAgent_t agent,
00588 int task_num,
00589 void **data,
00590 int *dim,
00591 int **extent);
00592
00598 EXPORTMC extern int MC_GetAgentStatus(MCAgent_t agent);
00599
00605 EXPORTMC extern enum MC_AgentType_e MC_GetAgentType(MCAgent_t agent);
00606
00612 EXPORTMC extern char* MC_GetAgentXMLString(MCAgent_t agent);
00613
00621 EXPORTMC extern int MC_HaltAgency(MCAgency_t agency);
00622
00633 EXPORTMC extern MCAgency_t MC_Initialize(
00634 int port,
00635 MCAgencyOptions_t *options);
00636
00649 EXPORTMC extern int MC_InitializeAgencyOptions(struct MCAgencyOptions_s* options);
00650
00656 EXPORTMC extern int MC_MainLoop(MCAgency_t attr);
00657
00672 EXPORTMC extern int MC_MutexLock(MCAgency_t attr, int id);
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684 EXPORTMC extern int MC_MutexUnlock(MCAgency_t attr, int id);
00685
00703 EXPORTMC extern int MC_RegisterService(
00704 MCAgency_t agency,
00705
00706
00707
00708 MCAgent_t agent,
00709 int agentID,
00710 const char *agentName,
00711 char **serviceNames,
00712 int numServices);
00713
00721 EXPORTMC extern int MC_ResumeAgency(MCAgency_t agency);
00722
00728 EXPORTMC extern MCAgent_t MC_RetrieveAgent(MCAgency_t attr);
00729
00741 EXPORTMC extern int MC_SemaphorePost(MCAgency_t attr, int id);
00742
00756 EXPORTMC extern int MC_SemaphoreWait(MCAgency_t attr, int id);
00757
00769 EXPORTMC extern int MC_SetDefaultAgentStatus(MCAgency_t agency, enum MC_AgentStatus_e status);
00770
00784 EXPORTMC extern int MC_SetThreadOn(MCAgencyOptions_t *options, enum MC_ThreadIndex_e index);
00785
00794 EXPORTMC extern int MC_SetThreadsAllOn(MCAgencyOptions_t* options);
00795
00809 EXPORTMC extern int MC_SetThreadOff(MCAgencyOptions_t *options, enum MC_ThreadIndex_e index );
00810
00819 EXPORTMC extern int MC_SetThreadsAllOff(MCAgencyOptions_t* options);
00820
00826 EXPORTMC extern int MC_PrintAgentCode(MCAgent_t agent);
00827
00833 EXPORTMC extern char * MC_RetrieveAgentCode(MCAgent_t agent);
00834
00842 EXPORTMC extern int MC_ResetSignal(MCAgency_t attr);
00843
00859 EXPORTMC extern int MC_SearchForService(
00860
00861 MCAgency_t attr,
00862 const char *searchString,
00863
00864 char*** agentNames,
00865 char*** serviceNames,
00866 int** agentIDs,
00867 int* numResults);
00868
00877 EXPORTMC extern int MC_SendAgentMigrationMessage(MCAgency_t attr,
00878 const char *message,
00879 const char *hostname,
00880 int port);
00881
00890 EXPORTMC extern int MC_SendAgentMigrationMessageFile(MCAgency_t attr,
00891 const char *filename,
00892 const char *hostname,
00893 int port);
00894
00903 EXPORTMC extern int MC_SetAgentStatus(MCAgent_t agent, int status);
00904
00920 EXPORTMC extern int MC_Steer( MCAgency_t attr, int (*funcptr)(void* data), void *arg);
00921
00930 EXPORTMC extern enum MC_SteerCommand_e MC_SteerControl(void);
00931
00940 EXPORTMC extern int MC_SyncDelete(MCAgency_t attr, int id);
00941
00957 EXPORTMC extern int MC_SyncInit(MCAgency_t attr, int id);
00958
00964 EXPORTMC extern int MC_TerminateAgent(MCAgent_t agent);
00965
00971
00972
00979 EXPORTMC extern int MC_WaitAgent(MCAgency_t attr);
00980
00989 EXPORTMC extern MCAgent_t MC_WaitRetrieveAgent(MCAgency_t attr);
00990
01004 EXPORTMC extern int MC_WaitSignal(MCAgency_t attr, int signals);
01005
01006 #ifdef __cplusplus
01007 }
01008 #endif
01009 #endif
01010