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
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
00118
00119
00120
00121
00122 #ifndef _MOBILEC_H_
00123 #define _MOBILEC_H_
00124
00125 #ifdef WIN32
00126 #ifdef _MC_DLL
00127
00128 #define EXPORTMC _declspec(dllexport)
00129 #else
00130
00131 #define EXPORTMC
00132 #endif
00133 #else
00134
00135 #define EXPORTMC
00136 #endif
00137
00138
00139
00140 #define MC_Wait(arg1) \
00141 MC_MainLoop(arg1)
00142
00143 #include <embedch.h>
00144 #ifdef __cplusplus
00145 extern "C" {
00146 #endif
00147
00148 #ifndef _ERROR_CODE_E_
00149 #define _ERROR_CODE_E_
00150
00151
00152
00153
00154 typedef enum error_code_e {
00155 MC_SUCCESS = 0,
00156 MC_ERR,
00157 MC_ERR_CONNECT,
00158 MC_ERR_PARSE,
00159 MC_ERR_EMPTY,
00160 MC_ERR_INVALID,
00161 MC_ERR_INVALID_ARGS,
00162 MC_ERR_NOT_FOUND,
00163 MC_ERR_MEMORY,
00164 MC_ERR_SEND,
00165 MC_WARN_DUPLICATE
00166 } error_code_t;
00167 #endif
00168
00172 enum MC_ThreadIndex_e{
00173 MC_THREAD_DF=0,
00174 MC_THREAD_AMS,
00175 MC_THREAD_ACC,
00176 MC_THREAD_CP,
00177 MC_THREAD_AGENT,
00178 MC_THREAD_ALL };
00179
00180
00184 typedef enum MC_SteerCommand_e {
00185 MC_RUN = 0,
00186 MC_SUSPEND,
00187 MC_RESTART,
00188 MC_STOP
00189 } MC_SteerCommand_t;
00190
00199 enum MC_Signal_e{
00200 MC_NO_SIGNAL =0x00,
00201 MC_RECV_CONNECTION=0x01,
00202 MC_RECV_MESSAGE =0x02,
00203 MC_RECV_AGENT =0x04,
00204 MC_RECV_RETURN =0x08,
00205 MC_EXEC_AGENT =0x0F,
00206 MC_ALL_SIGNALS =0x10
00207 };
00208
00212 typedef struct agency_s {
00213 int client;
00214 int server;
00215 char *hostName;
00216 char *filename;
00217 int portno;
00218 int portnoc;
00219 struct mc_platform_s* mc_platform;
00220 int default_agentstatus;
00221 int threads;
00222 int enable_security;
00223 int stack_size[MC_THREAD_ALL];
00224 error_code_t last_error;
00225 } agency_t;
00226 typedef agency_t* agency_p;
00227 typedef agency_p MCAgency_t;
00228
00232 typedef struct MCAgencyOptions_s{
00233 int threads;
00234 int default_agent_status;
00235 int modified;
00236 int enable_security;
00238
00239 int stack_size[MC_THREAD_ALL];
00240 } MCAgencyOptions_t;
00241
00242 #ifndef AGENT_T
00243 #define AGENT_T
00244 typedef struct agent_s agent_t;
00245 typedef agent_t* MCAgent_t;
00246 typedef agent_t* agent_p;
00247 #endif
00248
00249 enum MC_AgentType_e{ MC_NONE = -1, MC_REMOTE_AGENT = 0, MC_LOCAL_AGENT, MC_RETURN_AGENT };
00250
00254 enum MC_AgentStatus_e{
00255 MC_NO_STATUS = -1,
00256 MC_WAIT_CH = 0,
00257 MC_WAIT_MESSGSEND,
00258 MC_AGENT_ACTIVE,
00259 MC_AGENT_NEUTRAL,
00260 MC_AGENT_SUSPENDED,
00261 MC_WAIT_FINISHED
00262 };
00263
00264 struct fipa_acl_message_s;
00265
00273 EXPORTMC int
00274 MC_AclDestroy(struct fipa_acl_message_s* message);
00275
00281 EXPORTMC extern struct fipa_acl_message_s*
00282 MC_AclNew(void);
00283
00292 EXPORTMC extern int MC_AclPost(MCAgent_t agent, struct fipa_acl_message_s* message);
00293
00304 EXPORTMC extern struct fipa_acl_message_s*
00305 MC_AclReply(struct fipa_acl_message_s* acl_message);
00306
00314 EXPORTMC extern struct fipa_acl_message_s* MC_AclRetrieve(MCAgent_t agent);
00315
00324 EXPORTMC extern int MC_AclSend(MCAgency_t attr, struct fipa_acl_message_s* acl);
00325
00333 EXPORTMC extern struct fipa_acl_message_s* MC_AclWaitRetrieve(MCAgent_t agent);
00334
00335
00336 enum fipa_performative_e;
00337
00338 EXPORTMC int MC_AclSetPerformative(
00339 struct fipa_acl_message_s* acl,
00340 enum fipa_performative_e performative );
00341
00342 EXPORTMC int MC_AclSetSender(
00343 struct fipa_acl_message_s* acl,
00344 const char* name,
00345 const char* address );
00346
00347 EXPORTMC int MC_AclAddReceiver(
00348 struct fipa_acl_message_s* acl,
00349 const char* name,
00350 const char* address );
00351
00352 EXPORTMC int MC_AclAddReplyTo(
00353 struct fipa_acl_message_s* acl,
00354 const char* name,
00355 const char* address);
00356
00357 EXPORTMC int MC_AclSetContent(
00358 struct fipa_acl_message_s* acl,
00359 const char* content );
00360
00361
00362
00363
00372 EXPORTMC extern int MC_AddAgent(
00373 MCAgency_t attr,
00374 MCAgent_t agent);
00375
00391 extern const void*
00392 MC_AgentVariableRetrieve(
00393 MCAgent_t agent,
00394 const char* var_name,
00395 int task_num);
00396
00414 extern int
00415 MC_AgentVariableSave(MCAgent_t agent, const char* var_name);
00416
00426 EXPORTMC extern int MC_BarrierDelete(MCAgency_t attr, int id);
00427
00443 EXPORTMC extern int MC_BarrierInit(MCAgency_t attr, int id, int num_procs);
00444
00453 EXPORTMC extern int MC_ChInitializeOptions(MCAgency_t attr, ChOptions_t *options);
00454
00471 EXPORTMC extern int MC_CallAgentFunc(
00472 MCAgent_t agent,
00473 const char* funcName,
00474 void* returnVal,
00475 void* varg
00476 );
00477
00478
00492 MCAgent_t
00493 MC_ComposeAgent(
00494 const char* name,
00495 const char* home,
00496 const char* owner,
00497 const char* code,
00498 const char* return_var_name,
00499 const char* server,
00500 int persistent
00501 );
00502
00513 EXPORTMC extern int MC_CondBroadcast(MCAgency_t attr, int id);
00514
00530 EXPORTMC extern int MC_CondSignal(MCAgency_t attr, int id);
00531
00542 EXPORTMC extern int MC_CondReset(MCAgency_t attr, int id);
00543
00557 EXPORTMC extern int MC_CondWait(MCAgency_t attr, int id);
00558
00568 int MC_CopyAgent(MCAgent_t* agent_out, const MCAgent_t agent_in);
00569
00578 EXPORTMC extern int MC_DeleteAgent(MCAgent_t agent);
00579
00590 EXPORTMC extern int MC_End(MCAgency_t attr);
00591
00602 int MC_DestroyServiceSearchResult(
00603 char** agentName,
00604 char** serviceName,
00605 int* agentID,
00606 int numResult);
00607
00608
00619 EXPORTMC extern MCAgent_t MC_FindAgentByName(MCAgency_t attr, const char *name);
00620
00629 EXPORTMC extern MCAgent_t MC_FindAgentByID(MCAgency_t attr, int ID);
00630
00639 EXPORTMC extern void* MC_GetAgentExecEngine(MCAgent_t agent);
00640
00644 EXPORTMC extern int MC_GetAgentID(MCAgent_t agent);
00645
00646
00647
00648
00649
00650
00651 EXPORTMC extern char* MC_GetAgentName(MCAgent_t agent);
00652
00658 EXPORTMC extern int MC_GetAgentNumTasks(MCAgent_t agent);
00659
00676 EXPORTMC extern int MC_GetAgentReturnData(
00677 MCAgent_t agent,
00678 int task_num,
00679 void **data,
00680 int *dim,
00681 int **extent);
00682
00688 EXPORTMC extern int MC_GetAgentStatus(MCAgent_t agent);
00689
00695 EXPORTMC extern enum MC_AgentType_e MC_GetAgentType(MCAgent_t agent);
00696
00702 EXPORTMC extern char* MC_GetAgentXMLString(MCAgent_t agent);
00703
00711 EXPORTMC extern int MC_HaltAgency(MCAgency_t agency);
00712
00723 EXPORTMC extern MCAgency_t MC_Initialize(
00724 int port,
00725 MCAgencyOptions_t *options);
00726
00739 EXPORTMC extern int MC_InitializeAgencyOptions(struct MCAgencyOptions_s* options);
00740
00746 EXPORTMC extern int MC_MainLoop(MCAgency_t attr);
00747
00756 EXPORTMC extern int MC_LoadAgentFromFile(MCAgency_t attr, const char* filename);
00757
00772 EXPORTMC extern int MC_MutexLock(MCAgency_t attr, int id);
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784 EXPORTMC extern int MC_MutexUnlock(MCAgency_t attr, int id);
00785
00803 EXPORTMC extern int MC_RegisterService(
00804 MCAgency_t agency,
00805
00806
00807
00808 MCAgent_t agent,
00809 int agentID,
00810 const char *agentName,
00811 char **serviceNames,
00812 int numServices);
00813
00821 EXPORTMC extern int MC_ResumeAgency(MCAgency_t agency);
00822
00828 EXPORTMC extern MCAgent_t MC_RetrieveAgent(MCAgency_t attr);
00829
00841 EXPORTMC extern int MC_SemaphorePost(MCAgency_t attr, int id);
00842
00856 EXPORTMC extern int MC_SemaphoreWait(MCAgency_t attr, int id);
00857
00869 EXPORTMC extern int MC_SetDefaultAgentStatus(MCAgency_t agency, enum MC_AgentStatus_e status);
00870
00884 EXPORTMC extern int MC_SetThreadOn(MCAgencyOptions_t *options, enum MC_ThreadIndex_e index);
00885
00894 EXPORTMC extern int MC_SetThreadsAllOn(MCAgencyOptions_t* options);
00895
00909 EXPORTMC extern int MC_SetThreadOff(MCAgencyOptions_t *options, enum MC_ThreadIndex_e index );
00910
00919 EXPORTMC extern int MC_SetThreadsAllOff(MCAgencyOptions_t* options);
00920
00926 EXPORTMC extern int MC_PrintAgentCode(MCAgent_t agent);
00927
00933 EXPORTMC extern char * MC_RetrieveAgentCode(MCAgent_t agent);
00934
00942 EXPORTMC extern int MC_ResetSignal(MCAgency_t attr);
00943
00959 EXPORTMC extern int MC_SearchForService(
00960
00961 MCAgency_t attr,
00962 const char *searchString,
00963
00964 char*** agentNames,
00965 char*** serviceNames,
00966 int** agentIDs,
00967 int* numResults);
00968
00977 EXPORTMC extern int MC_SendAgentMigrationMessage(MCAgency_t attr,
00978 const char *message,
00979 const char *hostname,
00980 int port);
00981
00990 EXPORTMC extern int MC_SendAgentMigrationMessageFile(MCAgency_t attr,
00991 const char *filename,
00992 const char *hostname,
00993 int port);
00994
01003 EXPORTMC extern int MC_SetAgentStatus(MCAgent_t agent, int status);
01004
01020 EXPORTMC extern int MC_Steer( MCAgency_t attr, int (*funcptr)(void* data), void *arg);
01021
01030 EXPORTMC extern enum MC_SteerCommand_e MC_SteerControl(void);
01031
01040 EXPORTMC extern int MC_SyncDelete(MCAgency_t attr, int id);
01041
01057 EXPORTMC extern int MC_SyncInit(MCAgency_t attr, int id);
01058
01064 EXPORTMC extern int MC_TerminateAgent(MCAgent_t agent);
01065
01071
01072
01079 EXPORTMC extern int MC_WaitAgent(MCAgency_t attr);
01080
01089 EXPORTMC extern MCAgent_t MC_WaitRetrieveAgent(MCAgency_t attr);
01090
01104 EXPORTMC extern int MC_WaitSignal(MCAgency_t attr, int signals);
01105
01106 #ifdef __cplusplus
01107 }
01108 #endif
01109
01110 #endif
01111